package eerbaar.v2.gamebuilder;

import eerbaar.game.IGame;
import eerbaar.shared.exceptions.GameException;
import eerbaar.shared.persist.ISerializerService;
import eerbaar.shared.service.ServiceFactory;

public class GamePacket {

    private String data;

    public String getData() {
        return this.data;
    }

    public IGame getGame() throws GameException {
        assert (this.data != null);

        ISerializerService s = ServiceFactory
                .getService(ISerializerService.class);

        return s.load(IGame.class, this.data);
    }

    public void setGame(IGame node) throws GameException {
        assert (this.data == null);

        ISerializerService s = ServiceFactory
                .getService(ISerializerService.class);

        this.data = s.save(IGame.class, node);
    }

}
